package com.qdu.service.impl;

import java.math.BigInteger;
import java.util.List;
import java.util.Map;

//gitee.com/liqianru/project.git

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.qdu.controller.WebSocket;
//gitee.com/liqianru/project.git
import com.qdu.entity.Job;
import com.qdu.entity.Usert;
import com.qdu.entity.resumefile;
import com.qdu.mapper.UsertMapper;
import com.qdu.service.UsertService;

@Service
public class UsertServiceImpl implements UsertService{

 @Autowired
 private UsertMapper usertMapper;
 
 @Autowired
 private WebSocket socket;

 //增加新用户
 @Override
 public void addUsert(Usert usert) {
    usertMapper.insert(usert);
    usertMapper.insert2(usert.getUid(), usert.getUpwd());
    socket.SendMessage("增加了新用户");
 }


@Override
@Transactional(readOnly=true)
public List<Map<String,Object>> queryJobByjobName(String jobname,String bname) {
	return usertMapper.getListByName1(jobname,bname);
}


 //更新用户信息
@Override
public void updateUsert(Usert usert) {
	usertMapper.update(usert);
}

//更改用户密码
@Override
public void updateUpwd(Usert usert) {
	usertMapper.updateUpwd(usert);
	
}

//用户登录
@Override
public Usert login(String uid, String upwd) {
	Usert user = usertMapper.login(uid, upwd);
	if(user!=null && user.getUpwd().equals(upwd)) {
		return user;
	}
	return null;
}

//通过用户id获取用户信息
@Override
public Usert findUserbyuid(String uid) {
	Usert u = usertMapper.getOnebyuid(uid);
	return u;
}

//通过用户id获取用户密保问题
@Override
public Usert findUsertmibao(String uid) {
	Usert u = usertMapper.getMibao(uid);
	return u;
}

//通过用户输入密保问题答案找回密码
@Override
public Usert findUsertPwdBymibao(String uid,String upasswordexpre,String upasswordanswer) {
	Usert user = usertMapper.getPasswordbymibao(uid,upasswordexpre, upasswordanswer);
	return user;

}


//获取职业兴趣
@Override
public List<String> getInterestList() {
	return usertMapper.getInterestHad();
}
//通过用户邮箱重置密码
@Override
public Usert findUsertPwdByEmail(String uemail) {
	Usert user = usertMapper.getUserbyEmail(uemail);
	return user;

}


@Override
public BigInteger getProcess(String uid){
	// TODO Auto-generated method stub
	return null;
	}
//验证注册输入的用户名
@Override
public boolean isuidExist(String uid) {
	Integer count = usertMapper.isuidExist(uid);
	if(count.equals(0)) {
		return false;
	}
	return true;
}


@Override
public List<Usert> getAll() {
	return usertMapper.getAllactivUser();
}




@Override
public List<Map<String,Object>> queryJobByMult(String bpro,String education,String time,String salary) {
	List<Map<String,Object>> jobs=usertMapper.queryJobByMult(bpro,education, time, salary);
	return jobs;
}


@Override
public int addResume(String uid, String jid, String url) {
	
	return usertMapper.insertresumefile(uid, jid, url);
}

//l--
@Override
public List<Map<String,Object>> getresumeByuid(String uid) {
	// TODO Auto-generated method stub
	return usertMapper.getResumeByuid(uid);
}


@Override
public int ifHasemail(String uemail) {
	// TODO Auto-generated method stub
	return usertMapper.ifHasemail(uemail);
}




}